﻿#include "CPointManager.h"
#include <QDebug>
#include <QMessageBox>
#include "Global.h"
// 假设这里未来支持多种类型，现在只支持默认类型
CPointManager::CPointManager(QObject* parent) : QObject(parent) {}

CMeasurePoint* CPointManager::createPoint(const QString& type, const QString& name, CBaseNode* parent) {
	Q_UNUSED(type);
	// 后续可根据 type 区分 Analog、Digital、AI 等类型
	return new CMeasurePoint(name,"", "",parent, EPointType::enAnalog);
}

QMenu* CPointManager::createMenu(CMeasurePoint* point, QWidget* parent) {
	m_currentPoint = point;

	QMenu* menu = new QMenu(QString(A2T("测点: %1")).arg(point->getName()), parent);
	menu->addAction(A2T("查看数据"), this, SLOT(onViewData()));
	menu->addAction(A2T("设置属性"), this, SLOT(onSetAttributes()));
	return menu;
}

void CPointManager::onViewData() {
	if (!m_currentPoint) return;
	QMessageBox::information(nullptr, "查看数据",
		QString("当前测点 [%1] 的值为：xxx").arg(m_currentPoint->getName()));
}

void CPointManager::onSetAttributes() {
	if (!m_currentPoint) return;
	QMessageBox::information(nullptr, "设置属性",
		QString("可以为测点 [%1] 设置属性（模拟阈值等）").arg(m_currentPoint->getName()));
}
